/* 有弹窗的页面的通用逻辑
 * 需要提供添加，编辑接口 - currentAddApi, currentEditApi, beforeDialogClose - 关闭弹窗前的操作
-------------------------- */
const dialogCoreMixin = {
  data () {
    return {
      dialogVisible: false // 是否显示弹窗
    }
  },
  props: {
    showByToggle: Boolean // 通用boo值变化打开弹窗
  },
  watch: {
    // showByToggle变化时打开弹窗
    showByToggle () {
      this.dialogVisible = true
    }
  },
  methods: {
    beforeDialogClose () {},
    // 关闭弹窗
    dialogClose () {
      this.beforeDialogClose()
      this.dialogVisible = false
    },
    // 操作完成，关闭弹窗
    dialogComplete () {
      this.dialogClose()
      this.$emit('dialogComplete')
    }
  }
}

export default dialogCoreMixin
